package com.baibei.module;

import android.view.View;

import com.baibei.basic.BaibeiBasicFragment;
import com.baibei.model.UserInfo;
import com.rae.swift.session.SessionManager;
import com.umeng.analytics.MobclickAgent;

import butterknife.ButterKnife;
import butterknife.Unbinder;

public abstract class BasicFragment extends BaibeiBasicFragment implements UserStatus {
    Unbinder unbinder;

    @Override
    protected void onBindView(View view) {
        unbinder = ButterKnife.bind(this, view);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (unbinder != null) {
            unbinder.unbind();
        }
    }

    /**
     * 友盟统计事件
     *
     * @param event event
     */
    protected void onUmengEvent(String event) {
        MobclickAgent.onEvent(getContext(), event);
    }


    @Override
    public boolean isLogin() {
        return SessionManager.getDefault().isLogin();
    }

    @Override
    public boolean isRealName() {
        if (isLogin()) {
            UserInfo userInfo = SessionManager.getDefault().getUser();
            if (userInfo == null) {
                return false;
            }
            return userInfo.isPassRealNameVerify();
        }
        return false;
    }
}
